package o;

import android.util.Log;
import com.huawei.hmf.annotation.Inject;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import o.fig.e;

public class fih {
    static Map<fjb, fif> ˋ = new HashMap();
    private final fid ˎ;

    public fih(fid o_fid) {
        this.ˎ = o_fid;
    }

    public Object ˊ(Object obj) {
        if (obj instanceof fjl) {
            fjl clone = ((fjl) obj).clone();
            ˏ(clone);
            return clone;
        }
        ˎ(obj);
        return obj;
    }

    private void ˎ(Object obj) {
        if (obj != null) {
            for (Field field : obj.getClass().getDeclaredFields()) {
                Inject inject = (Inject) field.getAnnotation(Inject.class);
                if (inject != null) {
                    Object ॱ = ॱ(inject.value());
                    field.setAccessible(true);
                    try {
                        field.set(obj, ॱ);
                    } catch (IllegalAccessException e) {
                    }
                }
            }
        }
    }

    private void ˏ(fjl o_fjl) {
        for (Method method : o_fjl.getInterface().getDeclaredMethods()) {
            Inject inject = (Inject) method.getAnnotation(Inject.class);
            if (inject != null) {
                o_fjl.setValue(fjl.resolveName(method.getName()), ॱ(inject.value()));
            }
        }
    }

    private Object ॱ(String str) {
        fhz ˋ = fho.ˏ().ˋ(this.ˎ.getModuleName());
        if (ˋ == null) {
            Log.e("ModuleInjection", "lookup module failed with name " + this.ˎ.getModuleName());
            return null;
        }
        fig o_fig = this.ˎ.get(str);
        if (o_fig != null) {
            fie ॱ = fii.ॱ(o_fig.ˎ());
            if (ॱ != null) {
                fjb o_fjb = (fjb) ॱ.ॱ(ˋ, str);
                o_fjb.ॱ(o_fig.ˏ() == e.EXPLICIT_INJECT);
                return o_fjb;
            }
        }
        return ˋ.ˎ(str);
    }

    public static Set<String> ˏ(Class cls) {
        int i = 0;
        Set<String> hashSet = new HashSet();
        for (Field annotation : cls.getDeclaredFields()) {
            Inject inject = (Inject) annotation.getAnnotation(Inject.class);
            if (inject != null) {
                hashSet.add(inject.value());
            }
        }
        Method[] declaredMethods = cls.getDeclaredMethods();
        int length = declaredMethods.length;
        while (i < length) {
            inject = (Inject) declaredMethods[i].getAnnotation(Inject.class);
            if (inject != null) {
                hashSet.add(inject.value());
            }
            i++;
        }
        return hashSet;
    }

    public static fif ˋ(fjb o_fjb) {
        fif o_fif = (fif) ˋ.get(o_fjb);
        if (o_fif != null) {
            return o_fif;
        }
        o_fif = new fik();
        ˋ.put(o_fjb, o_fif);
        return o_fif;
    }
}
